import scipy.io as scio

import numpy as np
import matplotlib.pyplot as plt  # plt 用于显示图片
import matplotlib.image as img  # img 用于读取图片

img_1 = img.imread(r'D:\Project\Utils\dataset\ShanghaiTech\part_A\train_data\images\IMG_1.jpg')
plt.imshow(img_1)

dataFile = r'D:\Project\Utils\dataset\ShanghaiTech\part_A\train_data\ground-truth\GT_IMG_1.mat'
data = scio.loadmat(dataFile)
print(type(data['image_info']))
print(data['image_info'][0][0][0][0][0][0])
print(len(data['image_info'][0][0][0][0][0]))
x = []
y = []
for i in range(len(data['image_info'][0][0][0][0][0])):
    x.append(data['image_info'][0][0][0][0][0][i][0])
    y.append(data['image_info'][0][0][0][0][0][i][1])

plt.plot(x, y, 'r.')
plt.show()
# print(data.keys())
# data_test = r'D:\Project\Utils\dataset\ShanghaiTech\part_A\train_data\ground-truth\data_test.mat'
# scio.savemat(data_test, {'image_info': data['image_info']})
